<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>#(sys_title)</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../static/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/admin/login/login.css?v=3" media="all"/>
    <script src="../../static/js/aes.min.js"></script>
</head>
<style>
    body{ background:url(../../static/admin/images/9.jpg) 0% 0% / cover no-repeat; position:static; font-size:12px; }
    .login_qr, .login_pass{ cursor:pointer; color:#024b51 }
</style>
<body>
<div class="login display-show" id="LAY-user-login" style="display: none;">
    <input type="hidden" id="qr_uuid" value=""/>

    <div class="login-main" style="border:0px solid #ccc;border-radius: 5px;background:#FFFFFF;margin-top:20px;height:370px">
        <div class=" login-header" style="padding-top:20px">
            <h2>#(sys_title)</h2>

            <p>Version#(version)</p>
        </div>
        <div class="login-box login-body layui-form ">
            <div class="layui-form-item">
                <label class="login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名"
                       value="#(form.data.username)"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                       value="#(form.data.password)"
                       placeholder="密码" class="layui-input" style="background-color:#FFFFFF">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" value="#(form.data.vcode)"
                               lay-verify="required" lay-reqText="请输入四位图形验证码"
                               placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="ValidateCode" class="login-codeimg" id="LAY-user-get-vercode">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;text-align:center">
                <div class="layui-row">
                    <div class="layui-col-xs6" style="padding-right:5px;">
                        <button type="submit" class="layui-btn " lay-submit="submit1" lay-filter="submit1" style="width:100%;">登录</button>
                    </div>
                    <div class="layui-col-xs6" style="padding-left:5px">
                        <button type="reset" class="layui-btn layui-btn-primary " style="width:100%;">重置</button>
                    </div>
                </div>
            </div>
            <div class="layui-row layui-text" style="text-align:center;margin-bottom:20px;">
                <div class="login_qr color-8">微信扫码登陆</div>
            </div>
        </div>
        <div class="layui-fluid login-box-qr" style="display:none">
            <div class="layui-row" style="text-align:center;">
                <img src="../../static/admin/images/none.png" class="img_qrcode" style="width:200px;height:200px;margin:20px;">
            </div>
            <div class="layui-row layui-text" style="text-align:center;margin-bottom:20px">
                <div class="login_pass color-8">帐号密码登陆</div>
            </div>
        </div>
    </div>
</div>
<script src="../../static/plugins/layui/layui.js"></script>

<SCRIPT LANGUAGE="JavaScript">
    <!--
    function encrypt(word) {
        var key = CryptoJS.enc.Utf8.parse("abcdefghijk12345");
        var srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return encodeURIComponent(encrypted.toString());
    }

    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.$;
        form.on('submit(submit1)', function (data) {
            layer.load();
            data.field.username = encrypt(data.field.username);
            data.field.password = encrypt(data.field.password);
            layui.$.ajax({
                type: 'POST', url: "ValidateLoginApi",
                data: "postdata=" + JSON.stringify(data.field),
                success: function (results) {
                    layer.closeAll();
                    $("#user-get-vercode").attr("src", $("#user-get-vercode").attr("src") + '?' + Math.random());
                    if (results.code == 0) {
                        layer.msg("登录成功");
                        window.location.href = "../index";
                    } else {
                        layer.msg(results.msg);
                    }
                    return false;
                },
                error: function (return_data) {
                    layer.msg("系统异常");
                    return false;
                },
                dataType: "json"
            });
            return false;
        });

        var _time;

        //验证码重载
        $('.login-codeimg').on('click', function () {
            this.src = this.src + '?' + Math.random();
        });
        //扫码
        $('.login_qr').on('click', function () {
            $(".login-box").hide();
            $(".login-box-qr").show();
            $.get("getWxQrLoginApi", function (res) {
                $("#qr_uuid").val(res.keystring);
                $(".img_qrcode").attr("src", res.msg);
                clearInterval(_time);
                _time = setInterval(function () {
                    layui.$.get("getWxQrLoginStatusApi", {qr_uuid: $("#qr_uuid").val()}, function (res) {
                        if (res.code == 0) {
                            layer.msg("登录成功");
                            window.location.href = "../index";
                        } else if (res.code == 9) {
                            layer.msg(res.msg);
                            clearInterval(_time);
                        }
                    });
                }, 1000);
            });
        });
        //点码
        $('.img_qrcode').on('click', function () {
            var _this = this;
            $.get("getWxQrLoginApi", function (res) {
                $("#qr_uuid").val(res.keystring);
                _this.src = res.msg;
            });
        });
        //验证码重载
        $('.login_pass').on('click', function () {
            $(".login-box").show();
            $(".login-box-qr").hide();
        });
    });
    //-->
</SCRIPT>
</body>
</html>